package net.suncaper.demo.service;

import net.suncaper.demo.domain.*;
import net.suncaper.demo.mapper.StudentMapper;
import net.suncaper.demo.mapper.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherMapper teacherMapper;
    @Override
    public void savestudent(Student student) {
        studentMapper.insert(student);
    }
    @Override
    public void saveteacher(Teacher teacher) {
        teacherMapper.insert(teacher);
    }
    @Override
    public void deleteStudentById(String studentId) {
        studentMapper.deleteByPrimaryKey(studentId);
    }
    @Override
    public List<Student> findStudent() {
        return studentMapper.selectByExample(new StudentExample());
    }
    @Override
    public Student findStudentById(String studentId) {

        return studentMapper.selectByPrimaryKey(studentId);
    }
    @Override
    public void updateStudent(Student student){
        studentMapper.updateByPrimaryKey(student);
    }



    @Override
    public void deleteTeacherById(String teacherId) {
        teacherMapper.deleteByPrimaryKey(teacherId);
    }
    @Override
    public Teacher findTeacherById(String teacherId) {

        return teacherMapper.selectByPrimaryKey(teacherId);
    }
    @Override
    public void updateTeacher(Teacher teacher){
        teacherMapper.updateByPrimaryKey(teacher);
    }
    @Override
    public List<Teacher> findTeacher() {
        return teacherMapper.selectByExample(new TeacherExample());
    }
}
